<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet">
	<!-- 搜索样式CSS-Start -->
	<link href="/common/css/searchStyle.css" rel="stylesheet">
	<!-- 搜索样式CSS-End -->
	<!-- 下拉 -->
	<link href="/css/plugins/chosen/chosen.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- Example Events -->
                    <div class="example-wrap">
                        <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                             <form id="seachform">
	                             <div class="seach-context">
											 <label>参数配置名称 :</label><input id="name"placeholder="请输入客户名称"/>
											 <label>参数配置状态:</label>	
											 <select class="chosen-select" tabindex="8" id="status">
											 </select>
					             </div>
					            <button id="resetBtn" type="button" class="btn btn-w-m btn-white">重置</button>
								<button id="addBtn" type="button"  power="ADDPARAM" class="btn btn-w-m btn-success">新增</button>
								<button id="searchBtn" type="button" class="btn btn-w-m btn-white">查询</button>
							</form>
                        </div>
                        <table id="paramTable">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
	<!-- End Panel Other -->
	<script src="/js/jquery.min.js?v=2.1.4"></script>
	<script src="/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="/js/content.min.js?v=1.0.0"></script>
	<script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	<script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="/common/petecat.js"></script>
	<script src="/common/bootstrap-table-treetable.js"></script>
	<script src="/common/bootstrap-table.js"></script>
	<script src="/common/form.js"></script>
	<!-- HTML之间的传值 -->
	<script src="/js/jquery.params.js"></script>
	<script src="/js/plugins/layer-pc/layer.js"></script>
	<script src="/js/jquery.cookie.js"></script>
    <!-- 组件通用 -->
    <script src="/common/frame.js"></script>
    <!-- 下拉 -->
	<script src="/js/plugins/chosen/chosen.jquery.js"></script>
<script type="text/javascript">
	checkPowerAndJump("QRYPARAM");
    $(function(){
    	var status =JSON.parse('[{"key":"","value":"全部"},{"key":"0","value":"禁用"},{"key":"1","value":"启用"}]');
    	var item = {
    		id:"status",
    		data:status
    	};
    	initSelectData(item);
    	$('#resetBtn').click(function(){
    		$('#seachform').resetForm();
    	});
        $('#addBtn').click(function(){
            winLayerIndex = layer.open({
                type: 2,
                title: '新增参数配置',
                shade: 0.8,
                area: ['380px', '70%'],
                content: ['/base/param/add.html', 'auto'], //iframe的url，no代表不显示滚动条
                end: function(){ //此处用于演示
                    refreshGrid('paramTable');
                },
                success:function(){
                }
            });
        });

        $('#searchBtn').click(function(){
            refreshGrid('paramTable');
        });
        
        	var table = {};
        	table['id'] = 'paramTable';
        	table['url'] = BASE_URL+'/base/param/queryParamByPage',
        	table['pagination'] = true,
        	table['queryParams'] = function(params){
        		var queryParams = queryBaseParams(params);
                queryParams['name'] = $('#name').val();
                queryParams['status'] = $('#status').val();
                return queryParams;
        	};
        	table['columns'] = [{
	        	 field:'name',
	             title:'参数配置名称'
	        },{
	        	 field:'projectName',
	             title:'项目名称'
	        },{
	        	 field:'iupInterval',
	             title:'服务器上传间隔',
	             formatter:function(value,row,index){
	            	 return formatTime(value);
	             }
	        },{
	        	 field:'supInterval',
	             title:'软件上传间隔',
	             formatter:function(value,row,index){
	            	 return formatTime(value);
	             }
	        },{
	        	 field:'aupInterval',
	             title:'应用上传间隔',
	             formatter:function(value,row,index){
	            	 return formatTime(value);
	             }
	        },{
	        	 field:'hupInterval',
	             title:'硬件上传间隔',
	             formatter:function(value,row,index){
	            	 return formatTime(value);
	             }
	        },{
	        	 field:'createTime',
	             title:'参数配置创建时间',
	             formatter:function(value,row,index){
	            	 return timeTransfoDate(value);
	             }
	        },{
	            field:'status',
	            title:'参数配置状态',
	            formatter:function(value,row,index){
	            	return value==0?"禁用":"启用";
	            }
	        },{
	        	field : "opt",
	        	title:"操作",
	        	width: 200,
	        	formatter: function(value, row, index) {
	        		 var html = "";
	        		 if(row['status'] == 1){
	        			 if(checkPower("UPDPARAM")){
		       				 html+='<a class="edit" href="javascript:void(0)" title="修改">修改</a>&nbsp;&nbsp;&nbsp;';
		       		     }
	        		 }else{
	        			 if(checkPower("DELPARAM")){
							 html+= '<a class="del" href="javascript:void(0)" title="启用">启用</a>&nbsp;&nbsp;&nbsp;';
						 }
	        		 }
	        		 if(checkPower("DDELPARAM")){
	       				 html+='<a class="ddel" href="javascript:void(0)" style="color:red" title="删除">删除</a>&nbsp;&nbsp;&nbsp;';
	       		     }
					 return html;
	        	},
	            events:{
	                'click .edit':function(e, value, row, index){
	                	updWinLayerIndex = layer.open({
	                        type: 2,
	                        title: '修改参数配置信息',
	                        shade: 0.8,
	                        area: ['380px', '70%'],
	                        content: ['/base/param/edit.html', 'auto'], 
	                        end: function(){ //此处用于演示
	                            refreshGrid('paramTable');
	                        },
	                        success:function(layers,index){
	                            var body = layer.getChildFrame('body', index);
	                            var FormOptions = {};
	                            FormOptions['jsonValue'] = row;
	                            FormOptions['isDebug'] = true;
	                            body.find('#signupForm').initForm(FormOptions);
	                        }
	                    });
	                },
	        		'click .del':function(e, value, row, index){
	        			layer.confirm('如果启用后会把其他参数配置停用',{
	      					btn: ['是','否'],icon: 3, title:'是否启用当前得参数配置?'
	       				}, function(){
	    		        	var req = {};
	    		        	req['reqJSON'] = {
	    	        			type : 'delete',
	    	        			url : BASE_URL+'/base/param/updateParamById?paramId='+row.id+'&projectId='+row.projectId+'&state=1'
	    		        	};
	    		        	req['successFn'] = function(respData){
	    		        		layer.msg(respData.message, {icon: 6},function(){
	            				}); 
	    		        		if(respData.code == SUCCESS_CODE){
	    		        			refreshGrid('paramTable');
	        					}
	    		        	};
	    		        	ajaxRequest(req);
	       				});
	        		},
	        		'click .ddel':function(e, value, row, index){
	        			 if(row['status'] == 1){
	        				 layer.msg("不能删除正在启用的配置", {icon: 2}); 
	        				 return;
	        			 }
	        			layer.confirm('是否删除当前参数配置', {
	      					btn: ['是','否'] //按钮
	       				}, function(){
	    		        	var req = {};
	    		        	req['reqJSON'] = {
	    	        			type : 'delete',
	    	        			url : BASE_URL+'/base/param/removeParamById?paramId='+row.id
	    		        	};
	    		        	req['successFn'] = function(respData){
	    		        		layer.msg(respData.message, {icon: 6},function(){
	            				}); 
	    		        		if(respData.code == SUCCESS_CODE){
	    		        			refreshGrid('paramTable');
	        					}
	    		        	};
	    		        	ajaxRequest(req);
	       				});
	        		}
	        		
	            }
	        }];
        	initTable(table);
    });
</script>
</body>
</html>